package com.shelpe.service.simbaproxy.taobao;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

public class PreValidateFilter extends ZuulFilter{

    @Override
	public boolean shouldFilter() {
		return true;
	}

	@Override
	public Object run() {
		boolean validate = true;
		
		if(!validate){//如果没有验证通过，不予处理
			RequestContext ctx = RequestContext.getCurrentContext();
            ctx.set("error.status_code", "401");
            ctx.set("sendErrorFilter.ran");
        	ctx.set("error.message", "Oh, my god, it's an invalidate request!");
			RequestContext.getCurrentContext().setRouteHost(null);//将路由禁止
		}
		
		return null;
	}

	@Override
	public String filterType() {
		return "pre";
	}

	@Override
	public int filterOrder() {
		return 28;
	}

}